<template>

	<view class="message-list">

		<view class="message-list-li" v-for="(n,index) in list" @click="clickMessage">
			<view class="message-list-li-left">
				<userAvatar :src="n.avatar" :size="90"></userAvatar>
			</view>
			<view class="message-list-li-right">
				<view class="message-list-li-right-top">
					<userNameText username="测试用户名"></userNameText>
					<text class="message-date">3分钟前</text>
				</view>
				<view class="message-list-li-right-bottom">
					<text class="message-value">我是消息内容</text>
					<text class="message-badge">1</text>
				</view>
			</view>
		</view>
	</view>

</template>

<script setup>
	import userAvatar from '@/components/user_avatar/user_avatar.vue'
	import userNameText from '@/components/user_name_text/user_name_text'
	import {
		reactive,
		defineEmits,
		defineProps
	} from 'vue'
	
	const Emit = defineEmits("click")
	
	defineProps({
		list:{
			type:Array,
			default:()=>{
				return []
			}
		}
	})
	function clickMessage(m,index){
		Emit("click",m,index)
	}
</script>

<style>
	.message-list {
		display: flex;
		flex-direction: column;
	}

	.message-list-li {
		display: flex;
		border-bottom: 1rpx solid #c3c3c344;
		padding: 20rpx 30rpx;

	}

	.message-list-li:active {
		background-color: #c3c3c344;
	}

	.message-list-li-left {
		height: 100%;
		display: flex;
		align-items: center;
		margin-right: 20rpx;
	}

	.message-list-li-right {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 26rpx;
		padding-top: 10rpx;
	}

	.message-list-li-right-top {
		margin-bottom: 10rpx;
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
	}

	.message-list-li-right-bottom {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: gray;
	}

	.message-username {
		font-size: 30rpx;
	}

	.message-date {
		color: gray;
	}

	.message-badge {
		width: 25rpx;
		height: 25rpx;
		border-radius: 50%;
		background-color: red;
		color: white;
		text-align: center;
		line-height: 30rpx;
		font-size: 18rpx;
	}
</style>